using System.Collections.Generic;

namespace opt.Analysis.Graph
{
	public class Graph<T,U>
	{
		protected List<GraphNode<T,U>> _graph_roots;

		public int Count
		{
			get
			{
				return _graph_roots.Count;
			}
		}

		public GraphNode<T,U> this[int index]
		{
			get
			{
				if(index >= 0 && index < _graph_roots.Count)
					return _graph_roots[index];
				return null;
			}
			set
			{
				if(index >= 0 && index < _graph_roots.Count)
					_graph_roots[index] = value;
			}
		}

		public Graph()
		{
			_graph_roots = new List<GraphNode<T,U>>();
		}

		public void AddRoot(GraphNode<T,U> node)
		{
			_graph_roots.Add(node);
		}

		public void RemoveRoot(int index)
		{
			if(index >= 0 && index < _graph_roots.Count)
				_graph_roots.RemoveAt(index);
		}
	}
}
